<template>
  <div id="rose-chart">
    <div id="main2" style="height: 100%;"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts';


export default {
  name: 'RoseChart',
  data() {
    return {
      option: {},
    }
  },
  methods: {
    showCharts() {
      var myChart = echarts.init(document.querySelector("#main2"));      //1:获取dom元素
      // 绘制图表
      const option = {
        title: {
          text: '本月合格走势图',
          top:10,
          left:15,
          textStyle: {
            color: '#fff' // 这里设置标题颜色为红色
          }

        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          }
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        xAxis: [
          {
            type: 'category',
            data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
            axisTick: {
              alignWithLabel: true
            },
            axisLabel: {
              show: true,
              textStyle: {
                color: '#fff'
              }
            }
          }
        ],
        yAxis: [
          {
            type: 'value',
            axisLabel: {
              show: true,
              textStyle: {
                color: '#fff'
              }
            }
          }
        ],
        series: [
          {
            name: 'Direct',
            type: 'bar',
            barWidth: '50%',
            data: [10, 52, 200, 334, 390, 330, 220],
            itemStyle: {
              normal: {
                borderRadius: [10, 10, 0, 0],
                color: function () { return "#" + Math.floor(Math.random() * (256 * 256 * 256 - 1)).toString(16); }
              },
            },
          }
        ]
      };
      myChart.setOption(option);                              //3：挂载配置项
    },

  },
  mounted() {
    this.showCharts();
  },
}

</script>

<style lang="less">
#rose-chart {
  height: 100%;
  box-sizing: border-box;
  background-color: rgba(6, 30, 93, 0.5);
}
</style>
